exports.path = '/kafka/order/qryBTrade';
exports.title = '按条件查询匹配的在途订单 ';
exports.pool = 'kafka';

exports.sqltext = ({
  countRows,
}) => `
select ${countRows ? 'count(1) as amount' : 't.*'}
from tf_b_trade t
where t.serial_number = :serialNumber
and trade_type_code = :tradeTypeCode
`;

exports.outConverter = (sqlResult, req) => {
  if (req.countRows) return sqlResult.rows[0];
  return sqlResult.rows;
};

// 请求响应范例，用于调用者了解请求数据结构，也用于系统自动内测发起请求
exports.examples = [{
  desc: '查看指定号码携号转网CBS在途单数量',
  in: {
    countRows: 1,
    tradeTypeCode: '592',
    serialNumber: '13820374583',
  },
  out: {
    AMOUNT: 1,
  },
}];
